var k_edit = true;
$(window).load(function(){
       $('a').click(function(event){
		 event.preventDefault();
		  }); 	
  		CKEDITOR.on( 'instanceReady', function( evt ) {
			var editor = evt.editor;
			CKFinder.setupCKEditor( editor, { basePath : '/ckfinder/', skin : 'v1' } ) ;
			
		});
 	$('.dashboard').click(function(event){
  	 window.location = "/admin/dashboard/";
   	});
  	$('.go-back').click(function(event){
	  	window.history.back();
   	});
    var articleId ;
  	
    
  	$('.forsubmit').click(function(event){
  		  var ckvalue2 = CKEDITOR.instances.editor2.getData();
  		  var submit ={
			type : "POST",
			dataType : "json",
			data  : {title: $('.entity_title').text(), content : ckvalue2},
			success : function(data){		
				if(data && data.state && (data.state.indexOf("ERROR") != -1)){
					return;	
				}else{
				if (data.entity){
			       articleId =data.entity
			      }
					alert("update successfully");				 	
				}
			  }
		    };  	 
		    
  		if (articleId){
   	    submit.url = '/sisv-announcement/'+articleId+'/edit/';
   	   }	
 		$.ajax(submit);	
 
  	});
});